import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

public class Leet17_13 {
    public static void main(String[] args) {
        System.out.println(respace(new String[]{"vprkj","sqvuzjz","ptkrqrkussszzprkqrjrtzzvrkrrrskkrrursqdqpp","spqzqtrqs","rkktkruzsjkrzqq","rk","k","zkvdzqrzpkrukdqrqjzkrqrzzkkrr","pzpstvqzrzprqkkkd","jvutvjtktqvvdkzujkq","r","pspkr","tdkkktdsrkzpzpuzvszzzzdjj","zk","pqkjkzpvdpktzskdkvzjkkj","sr","zqjkzksvkvvrsjrjkkjkztrpuzrqrqvvpkutqkrrqpzu"},"rkktkruzsjkrzqqzkvdzqrzpkrukdqrqjzkrqrzzkkrr"));
    }
    static public int respace(String[] dictionary, String sentence) {
        int num = 0;
        Set<String> set = new HashSet<>(Arrays.asList(dictionary));
        StringBuilder sb;
        for (int i = 0; i < sentence.length(); i++) {
            sb = new StringBuilder();
            for (int j = i; j < sentence.length(); j++) {
                sb.append(sentence.charAt(j));
                if (set.contains(sb.toString())){
                    num+=sb.length();
                    i = j;
                    break;
                }
            }
        }
        return sentence.length()-num;
    }
}
